#include "mainwindow.h"

#include <person.h>

#include <QDebug>
#include <QMenuBar>
#include <QPixmap>
#include <QMessageBox>


MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
    this->log = LogUtil::getLogger("mainwindow");
    
    this->resize(800, 600);
    this->setWindowTitle("第一个 qt6 程序");

    auto person = std::make_unique<Person>();

    QMenuBar *menubar = this->menuBar();
    this->setMenuBar(menubar);
    this->m_menu_file    = menubar->addMenu("文件");
    this->m_act_file_new = this->m_menu_file->addAction("新建");
    this->m_act_file_new->setIcon(QPixmap(":/icons/new.png"));

    connect(this->m_act_file_new, &QAction::triggered, [&]() {
        SPDLOG_LOGGER_INFO(this->log,fmt::format("person say {}",person->sayHello().toStdString()));
        qDebug() << person->sayHello();
        QMessageBox msgBox;
        msgBox.setText(person->sayHello());
        msgBox.exec();
    });
}

MainWindow::~MainWindow() {}
